import pika


connection = pika.BlockingConnection()
channel = connection.channel()
channel.exchange_declare(exchange="reject-exchange",
                         exchange_type="direct",
                         passive=False,
                         durable=False,
                         auto_delete=False)
channel.queue_declare(queue="reject-queue")
channel.queue_bind(queue="reject-queue",
                   exchange="reject-exchange",
                   routing_key="hola")

channel.basic_publish(body="reject_message",
                      exchange="reject-exchange",
                      routing_key="hola")

def on_message(channel, method_frame, header_frame, body):
    print(method_frame.delivery_tag)
    print(body)
    channel.basic_reject(delivery_tag=method_frame.delivery_tag,requeue=False)
    
channel.basic_consume(on_message,'reject-queue')
try:
    channel.start_consuming()
except KeyboardInterrupt:
    channel.stop_consuming()
connection.close()
